package Java.j2;

import java.util.Scanner;

public class AcWing_668 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // 读取开始时间的小时和分钟
        int startHour = scanner.nextInt();
        int startMinute = scanner.nextInt();
        // 读取结束时间的小时和分钟
        int endHour = scanner.nextInt();
        int endMinute = scanner.nextInt();

        // 将开始和结束时间转换为分钟数
        int startTotalMinutes = startHour * 60 + startMinute;
        int endTotalMinutes = endHour * 60 + endMinute;

        // 计算持续时间的分钟数
        int durationMinutes;
        if (endTotalMinutes <= startTotalMinutes) {
            // 若结束时间早于或等于开始时间，说明跨天了，加上一天的分钟数
            durationMinutes = endTotalMinutes + 24 * 60 - startTotalMinutes;
        } else {
            durationMinutes = endTotalMinutes - startTotalMinutes;
        }

        // 处理持续时间最短为 1 分钟的情况
        if (durationMinutes == 0) {
            durationMinutes = 24 * 60;
        }

        // 计算小时数和剩余分钟数
        int hours = durationMinutes / 60;
        int minutes = durationMinutes % 60;

        // 输出结果
        System.out.printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n", hours, minutes);

        scanner.close();
    }
}
